import java.util.*;

public class Test2 {
	public static void main(String[] args) {
		int cnt = 0;
		int count0 = 0;
		int count2 = 0;
		int count5 = 0;
		for(int i = 1; i <= 20250412; i++) {
			int t = i;
			while(t != 0) {
				int tmp = t % 10;
				t /= 10;
				if(tmp == 0) {
					count0++;
				}
				if(tmp == 2) {
					count2++;
				}
				if(tmp == 5) {
					count5++;
				}
			}
			if(count0 >= 1 && count2 >= 2 && count5 >= 1) {
				//System.out.println(i);
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}
